import { Divider } from "element-ui";
import { RouterView } from "vue-router";

export default {
  data() {
    return {
      show2: true,
      showMain: false,
      activeIndex: "1",
    };
  },
  methods: {
    // 登出方法
    logout() {
      this.$message.success("退出成功");
      this.$router.push("/admin/login");
      localStorage.removeItem("activeIndex");
      localStorage.removeItem("token");
    },
    // 导航下标获取
    handleSelect(key) {
      this.activeIndex = key;
      localStorage.setItem("activeIndex", this.activeIndex);
    },
  },
  // 生命周期
  mounted() {
    this.activeIndex = localStorage.getItem("activeIndex");
    // 底部导航栏点击事件
    const lis = document.querySelectorAll(".nav li");
    lis.forEach((li) =>
      li.addEventListener("click", function () {
        lis.forEach((item) => {
          item.classList.remove("active");
          this.classList.add("active");
        });
      })
    );
  },
  created: function () {
    // 页面进入执行方法
    this.$store.dispatch("getAdmin");
  },
  components: { RouterView, Divider },
};
